<template>
    <div>
        <!--    搜索表单-->
        <div>
            <div style="float: left;top:0px">
                <i style="font-size: x-large" class="el-icon-document-checked"></i><span
                    style="font-weight:bold;font-size:x-large">处置项目查看</span>
            </div>
            <br>
            <el-divider></el-divider>
            <div>
                <el-input v-model="inputCaseNumber" style="width: 257px;float: left;" placeholder="请输入患者病历号"></el-input>
                <el-input v-model="inputRealName" style="width: 257px; margin-left: 20px;float: left;"
                    placeholder="请输入患者姓名"></el-input>
                <el-button style="margin-left: 25px;float: left" type="primary" @click="select"> 搜索</el-button>
                <br>
            </div>
            <br> <br>
        </div>
        <el-divider></el-divider>
        <el-table :data="tableData" style="width: 100%">
            <el-table-column label="编号" prop="id">
            </el-table-column>
            <el-table-column label="患者姓名" prop="realName">
            </el-table-column>
            <el-table-column label="患者病历号" prop="caseNumber">
            </el-table-column>
            <el-table-column label="患者年龄" prop="age">
            </el-table-column>
            <el-table-column label="患者性别" prop="gender">
            </el-table-column>
            <el-table-column align="right">
                <template v-slot="scope">
                    <el-button type="primary" :plain="true" @click="selectById(scope.$index, scope.row)">处置项目</el-button>
                </template>
            </el-table-column>
        </el-table>

    </div>
</template>
<script>
import axios from "axios";

export default {
    created() {
    },
    data() {
        return {
            inputCaseNumber: '',
            inputRealName: '',
            form: {},
            tableData: [],
            search: ''
        }
    },
    methods: {
        async select() {
            //根据name换id
            //参数：String deptName
            await axios.post("http://127.0.0.1:8088/disposal/select", { caseNumber: this.inputCaseNumber, realName: this.inputRealName }).then((res) => {

                this.tableData = res.data.data
                console.log(this.tableData)

            });
        },
        async selectById(index, row) {
            //根据name换id
            //参数：String deptName
            await axios.post("http://127.0.0.1:8088/disposal/selectById", { params: { id: row.id } }).then((res) => {

                this.tableData = res.data.data
                console.log(this.tableData)
                this.$message({
                    message: '申请成功',
                    type: 'success'
                });

                //跳转到病历首页,并进行参数传递
                this.$router.push({
                    name: '患者录入',
                    params: {
                        registerId: row.id,
                    }
                });
            }).catch(error => {
                this.$message.error('申请失败');
            })
        },
        open() {
            this.$alert('此患者的检查项目:XXXXXX', {
                confirmButtonText: '确定',
                callback: action => {
                    this.$message({
                        type: 'info',
                        message: `action: ${action}`
                    });
                }
            });
        },
        handleChangePass(row) {
            this.form = JSON.parse(JSON.stringify(row))
            this.dialogFormVisible = true
        },
        handleEdit(index, row) {
            console.log(index, row);
        },
        handleDelete(index, row) {
            console.log(index, row);
        }
    },
    async mounted() {
        //获取病历号
        await axios.get("http://127.0.0.1:8088/disposal/query").then((res) => {
            this.tableData = res.data.data
            console.log(this.tableData)
        });
    }
}
</script>